Page({
  data: {
    artistInfo: {
      name: '',
      desc: '',
      avatar: '',
      following: 0,
      followers: 0
    },
    isFollowing: false,
    songs: [],
    posters: []
  },
  
  onLoad(options) {
    const artistName = decodeURIComponent(options.name || '未知歌手')
    this.loadArtistInfo(artistName)
  },
  
  loadArtistInfo(name) {
    // 模拟数据，实际项目中应该从服务器获取
    const mockData = {
      '隔层': {
        name: '隔层',
        desc: '隔层',
        avatar: 'https://picsum.photos/seed/artist1/200',
        following: 128,
        followers: 2560,
        songs: [
          { id: 1, name: '火', playCount: 12580 },
          { id: 2, name: '夜光', playCount: 8920 },
          { id: 3, name: '梦境', playCount: 6540 }
        ],
        posters: [
          { id: 1, title: '火', desc: '电子音乐代表作', url: 'https://images.unsplash.com/photo-1493225457124-a3eb161ffa5f?w=400' },
          { id: 2, title: '夜光', desc: '迷幻电子风格', url: 'https://images.unsplash.com/photo-1511671782779-c97d3d27a1d4?w=400' },
          { id: 3, title: '梦境', desc: '氛围音乐', url: 'https://images.unsplash.com/photo-1571019613454-1cb2f99b2d8b?w=400' }
        ]
      },
      '坤坤': {
        name: '坤坤',
        desc: '坤坤',
        avatar: 'https://picsum.photos/seed/artist2/200',
        following: 89,
        followers: 1890,
        songs: [
          { id: 4, name: '只因你太美', playCount: 25680 },
          { id: 5, name: '篮球梦', playCount: 12340 },
          { id: 6, name: '青春无悔', playCount: 9870 }
        ],
        posters: [
          { id: 4, title: '只因你太美', desc: '经典流行歌曲', url: 'https://images.unsplash.com/photo-1470225620780-dba8ba36b745?w=400' },
          { id: 5, title: '篮球梦', desc: '运动主题音乐', url: 'https://images.unsplash.com/photo-1546519638-68e109498ffc?w=400' },
          { id: 6, title: '青春无悔', desc: '青春励志歌曲', url: 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=400' }
        ]
      },
      '智子涵': {
        name: '智子涵',
        desc: '智子涵',
        avatar: 'https://picsum.photos/seed/artist3/200',
        following: 156,
        followers: 3200,
        songs: [
          { id: 7, name: '六六六', playCount: 18900 },
          { id: 8, name: '青春年华', playCount: 11200 },
          { id: 9, name: '梦想起航', playCount: 8900 }
        ],
        posters: [
          { id: 7, title: '六六六', desc: '网络热门歌曲', url: 'https://images.unsplash.com/photo-1493225457124-a3eb161ffa5f?w=400' },
          { id: 8, title: '青春年华', desc: '校园青春主题', url: 'https://images.unsplash.com/photo-1511671782779-c97d3d27a1d4?w=400' },
          { id: 9, title: '梦想起航', desc: '励志追梦歌曲', url: 'https://images.unsplash.com/photo-1571019613454-1cb2f99b2d8b?w=400' }
        ]
      }
    }
    
    const artist = mockData[name] || {
      name: name,
      desc: '音乐人',
      avatar: 'https://picsum.photos/seed/default/200',
      following: 0,
      followers: 0,
      songs: []
    }
    
    this.setData({
      artistInfo: artist,
      songs: artist.songs,
      posters: artist.posters || []
    })
  },
  
  toggleFollow() {
    const isFollowing = !this.data.isFollowing
    this.setData({ isFollowing })
    
    wx.showToast({
      title: isFollowing ? '已关注' : '已取消关注',
      icon: 'none'
    })
  },
  
  playSong(e) {
    const id = e.currentTarget.dataset.id
    const song = this.data.songs.find(s => s.id === id)
    if (song) {
      wx.showToast({
        title: `播放: ${song.name}`,
        icon: 'none'
      })
    }
  }
})
